package com.project.web.intfc.controller.core;

import com.project.web.intfc.controller.common.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yun.common.utils.redis.RedisClient;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 手机验证码控制器
 *
 * @author WYY
 * @date 2017/11/30
 */
@Controller("interfaceMobileController")
@RequestMapping("/interface/mobile")
public class MobileController extends BaseController {
    private static final long serialVersionUID = 7511558608452420040L;

    @Resource(name = "redisClient")
    private RedisClient redisClient;

//    @Resource(name = "SMSServiceImpl")
//    private SMSService smsService;

    /**
     * 获取阿里云.云通信短信验证码【短信验证码】
     *
     * @param mobile 短信验证码
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/captcha")
    public Map<String, Object> captcha(String mobile) {
        // 初始化返回MAP集合
        Map<String, Object> map = new HashMap<String, Object>();

        // 根据Redis校验验证码
        /*String exists = redisClient.getString(RedisConsts.WXMEMBER_MOBILECODE_LIMIT_KEY + mobile);
        Object cacheCode = redisClient.get(RedisConsts.WXMEMBER_MOBILE_CAPTCHA + mobile);
        if (StringUtils.isNotBlank(exists)) {
            throw new CustomException(RESPONSE_CODE_ENUM.CAPTCHA_EXIST);
        }*/

        //生成验证码，放入redis缓存
       /* String captcha = RandomStringUtils.randomNumeric(6);
        redisClient.setAndExpire(RedisConsts.WXMEMBER_MOBILE_CAPTCHA + mobile, captcha, RedisConsts.WXMEMBER_MOBILE_CAPTCHA_EXPIRE);

        //发送短信
        smsService.sendAliSMSForFGeneral(mobile, captcha);
        map.put("success", true);*/
        return getResult(map);
    }
}